package ru.paswd.marketprice.api

import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.PUT
import retrofit2.http.Query
import ru.paswd.marketprice.api.dto.*
import java.util.*

interface Api {
    companion object {
        private const val API_HREF = "/api/v1/"
    }

    @GET(API_HREF + "product/categories")
    fun getCategories(): Call<List<ProductCategory>>

    @GET(API_HREF + "product/products")
    fun getProducts(
            @Query("name") name: String?,
            @Query("category") category: String?
    ): Call<Page<Product>>

    @GET(API_HREF + "product/priceList")
    fun getPriceList(
            @Query("productId") productId: UUID,
            @Query("radiusMeters") radiusMeters: Int?,
            @Query("lat") lat: Double,
            @Query("lng") lng: Double,
            @Query("sortByPrice") sortByPrice: Boolean
    ): Call<List<PriceWithShop>>

    @GET(API_HREF + "product/priceHistory")
    fun getPriceHistory(
            @Query("productId") productId: UUID,
            @Query("shopId") shopId: UUID
    ): Call<List<Price>>

    @PUT(API_HREF + "product/save")
    fun saveReceipt(
            @Body receiptInfo: ReceiptInfo
    ): Call<Void>
}